package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.BdLine;
import com.example.demo.mapper.LineMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/line")
public class LineController {

    @Resource
    private LineMapper lineMapper;

@PostMapping
public Result<?> save(@RequestBody BdLine BdLine) {
    lineMapper.insert(BdLine);
    return Result.success();
}

    @PutMapping
    public Result<?> update(@RequestBody BdLine BdLine) {
        lineMapper.updateById(BdLine);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result<?> delete(@PathVariable Integer id) {
        lineMapper.deleteById(id);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result<?> getById(@PathVariable Integer id) {
        return Result.success(lineMapper.selectById(id));
    }

    @GetMapping
    public Result<?> findAll() {;

        return Result.success(lineMapper.selectList(null));
    }


}
